
#ifndef SERRVER_STRUCT_H
#define SERRVER_STRUCT_H
#include <iocpserver.h>
#include "Const.h"
struct SERVER_KEY 
{   
	eSERVER_TYPE m_Type;
	WORD m_ChannelID;
	WORD m_WorldID;
	WORD m_ServerID;
	SERVER_KEY(int i){m_ChannelID=i;}
	SERVER_KEY(){}

	void Set(DWORD WorldID,DWORD ChannelID,eSERVER_TYPE Type,DWORD ServerID)
	{
		m_WorldID = WorldID;
		m_ChannelID = ChannelID;
		m_Type = Type;
		m_ServerID = ServerID;
	}
	WORD				GetChannelID() { return m_ChannelID;	}
	WORD				GetWorldID() { return m_WorldID;	}
	WORD				GetServerID() { return m_ServerID; }

} ;

struct SERVER_ENV
{   
	//[Common]
	bool bGMListApply;
	bool bGetServerInfoFromFile;
	bool bGmListApply;
	BYTE cbFieldServerType;
	BYTE cbBattleServerType; 	
	bool bVillageRenderInfo;
	bool bySunLogOption;
	BYTE byFieldServerType;
	BYTE byBattleServerType;
	char pszLogPath[64];
	//[IOHandler]
	//[MaseterServer]
	char pszMasterServerIP[16];
	WORD wMasterServerPort;
	//[ACCOUNTDBPROXYSERVER]
	char pszAccountDBProxyServerIP[16];
	WORD wAccountDBProxyServerPort;
	//[GAMEDBPROXYSERVER]
	char pszGameDBProxyServerIP[16];
	WORD wGameDBProxyServerPort;
	//[AGENTSERVER]
	char pszAgentServerOutSideIP[16];
	WORD wAgentServerOutSidePort;
	char pszAgentServerInSideIP[16];
	WORD wAgentServerInSidePort;
	//[PORTALSERVER]
	char pszPortalServerIP[16];
	WORD wPortalServerPort;
	//[AUTHAGENTSERVER]
	bool bEnableAuthAgentServer;
	WORD wAgentServerID;
	char pszAuthAgentServerIP[16];
	WORD wAuthAgentServerPort;
	char pszGroupName[16];
	char pszServerName[16];
	//[GUILDSERVER]
	char pszGuildServerIP[16];
	WORD wGuildServerPort;
	//
	char pszWorldServerIP[16];
	WORD wWorldServerPort;
	char pszWorldServerClientIP[16];
	WORD wWorldServerClientPort;
	//log

	//user
	DWORD dwMaxUser; 


};

class CFileParser
{
	SERVER_ENV  m_Server_env;
public:
	bool ParseInitFile(char* strName)
	{   
		char str[64];
		char name[64];
		sprintf(name,".//%s",strName);
		//common
		GetPrivateProfileString("COMMON","GET_SERVERINFO_FROM_FILE",NULL,str,sizeof(str),name);
		m_Server_env.bGetServerInfoFromFile = atoi((const char*)str);
		GetPrivateProfileString("COMMON","GMLIST_APPLYE",NULL,str,sizeof(str),name);
		m_Server_env.bGmListApply = atoi((const char*)str);
		GetPrivateProfileString("COMMON","FIELD_SERVER_TYPE",NULL,str,sizeof(str),name);
		m_Server_env.cbFieldServerType = atoi((const char*)str);
		GetPrivateProfileString("COMMON","BATTLE_SERVER_TYPE",NULL,str,sizeof(str),name);
		m_Server_env.cbBattleServerType = atoi((const char*)str);
		GetPrivateProfileString("COMMON","VILLAGE_RENDERINFO",NULL,str,sizeof(str),name);
		m_Server_env.bVillageRenderInfo = atoi((const char*)str);
		//
		GetPrivateProfileString("CLIENT_IOHANDLER","MAX_ACCEPT_SESSION",NULL,str,sizeof(str),name);
		m_Server_env.ClientIoHandler.dwMaxAcceptSession = atoi((const char*)str);
		GetPrivateProfileString("CLIENT_IOHANDLER","MAX_CONNECT_SESSION",NULL,str,sizeof(str),name);
		m_Server_env.ClientIoHandler.dwMaxConnectSession = atoi((const char*)str);
		GetPrivateProfileString("CLIENT_IOHANDLER","SEND_BUFFER_SIZE",NULL,str,sizeof(str),name);
		m_Server_env.ClientIoHandler.dwSendBufferSize = atoi((const char*)str);
		GetPrivateProfileString("CLIENT_IOHANDLER","RECV_BUFFER_SIZE",NULL,str,sizeof(str),name);
		m_Server_env.ClientIoHandler.dwRecvBufferSize = atoi((const char*)str);
		GetPrivateProfileString("CLIENT_IOHANDLER","MAX_PACKET_SIZE",NULL,str,sizeof(str),name);
		m_Server_env.ClientIoHandler.dwMaxPacketSize = atoi((const char*)str);
		GetPrivateProfileString("CLIENT_IOHANDLER","NUMBER_OF_ACCEPT_THREADs",NULL,str,sizeof(str),name);
		m_Server_env.ClientIoHandler.dwNumberOfAcceptThreads = atoi((const char*)str);
		GetPrivateProfileString("CLIENT_IOHANDLER","NUMBER_OF_CONNECT_THREADS",NULL,str,sizeof(str),name);
		m_Server_env.ClientIoHandler.dwNumberOfConnectThreads = atoi((const char*)str);
		GetPrivateProfileString("CLIENT_IOHANDLER","NUMBER_OF_IO_THREADS",NULL,str,sizeof(str),name);
		m_Server_env.ClientIoHandler.dwNumberOfIoThreads = atoi((const char*)str);
		GetPrivateProfileString("CLIENT_IOHANDLER","TIME_OUT",NULL,str,sizeof(str),name);
		m_Server_env.ClientIoHandler.dwTimeOut = atoi((const char*)str);
		//
		GetPrivateProfileString("SERVER_IOHANDLER","MAX_ACCEPT_SESSION",NULL,str,sizeof(str),name);
		m_Server_env.ServerIoHandler.dwMaxAcceptSession = atoi((const char*)str);
		GetPrivateProfileString("SERVER_IOHANDLER","MAX_CONNECT_SESSION",NULL,str,sizeof(str),name);
		m_Server_env.ServerIoHandler.dwMaxConnectSession = atoi((const char*)str);
		GetPrivateProfileString("SERVER_IOHANDLER","SEND_BUFFER_SIZE",NULL,str,sizeof(str),name);
		m_Server_env.ServerIoHandler.dwSendBufferSize = atoi((const char*)str);
		GetPrivateProfileString("SERVER_IOHANDLER","RECV_BUFFER_SIZE",NULL,str,sizeof(str),name);
		m_Server_env.ServerIoHandler.dwRecvBufferSize = atoi((const char*)str);
		GetPrivateProfileString("SERVER_IOHANDLER","MAX_PACKET_SIZE",NULL,str,sizeof(str),name);
		m_Server_env.ServerIoHandler.dwMaxPacketSize = atoi((const char*)str);
		GetPrivateProfileString("SERVER_IOHANDLER","NUMBER_OF_ACCEPT_THREADs",NULL,str,sizeof(str),name);
		m_Server_env.ServerIoHandler.dwNumberOfAcceptThreads = atoi((const char*)str);
		GetPrivateProfileString("SERVER_IOHANDLER","NUMBER_OF_CONNECT_THREADS",NULL,str,sizeof(str),name);
		m_Server_env.ServerIoHandler.dwNumberOfConnectThreads = atoi((const char*)str);
		GetPrivateProfileString("SERVER_IOHANDLER","NUMBER_OF_IO_THREADS",NULL,str,sizeof(str),name);
		m_Server_env.ServerIoHandler.dwNumberOfIoThreads = atoi((const char*)str);
		GetPrivateProfileString("SERVER_IOHANDLER","TIME_OUT",NULL,str,sizeof(str),name);
		m_Server_env.ServerIoHandler.dwTimeOut = atoi((const char*)str);
		//
		GetPrivateProfileString("AGENTSERVER","AGENTSERVER_OUTSIDE_IP",NULL,m_Server_env.pszAgentServerOutSideIP,sizeof(m_Server_env.pszAgentServerOutSideIP),name);
		GetPrivateProfileString("AGENTSERVER","AGENTSERVER_OUTSIDE_PORT",NULL,str,sizeof(str),name);
		m_Server_env.wAgentServerOutSidePort = atoi((const char*)str);
		GetPrivateProfileString("AGENTSERVER","AGENTSERVER_INSIDE_IP",NULL,m_Server_env.pszAgentServerInSideIP,sizeof(m_Server_env.pszAgentServerInSideIP),name);
		GetPrivateProfileString("AGENTSERVER","AGENTSERVER_INSIDE_PORT",NULL,str,sizeof(str),name);
		m_Server_env.wAgentServerInSidePort = atoi((const char*)str);
		//
		GetPrivateProfileString("AUTHAGENTSERVER","AUTHAGENTSERVER_IP",NULL,m_Server_env.pszAuthAgentServerIP,sizeof(m_Server_env.pszAuthAgentServerIP),name);
		GetPrivateProfileString("AUTHAGENTSERVER","AUTHAGENTSERVER_PORT",NULL,str,sizeof(str),name);
		m_Server_env.wAuthAgentServerPort = atoi((const char*)str);
        //
		//Account DB
		GetPrivateProfileString("ACCOUNTDBPROXYSERVER","ACCOUNTDBPROXYSERVER_IP",NULL,m_Server_env.pszAccountDBProxyServerIP,sizeof(m_Server_env.pszAccountDBProxyServerIP),name);
		GetPrivateProfileString("ACCOUNTDBPROXYSERVER","ACCOUNTDBPROXYSERVER_PORT",NULL,str,sizeof(str),name);
		m_Server_env.wAccountDBProxyServerPort = atoi((const char*)str);
		//Game DB
		GetPrivateProfileString("GAMEDBPROXYSERVER","GAMEDBPROXYSERVER_IP",NULL,m_Server_env.pszGameDBProxyServerIP,sizeof(m_Server_env.pszGameDBProxyServerIP),name);
		GetPrivateProfileString("GAMEDBPROXYSERVER","GAMEDBPROXYSERVER_PORT",NULL,str,sizeof(str),name);
		m_Server_env.wGameDBProxyServerPort = atoi((const char*)str);

		m_Server_env.dwMaxUser = 0x0A;
		return true;
	}
	SERVER_ENV* GetServerEnv()
	{
		return &m_Server_env;

	}

};
#endif

